$(function(){
    var productId = CommonUtils.uncompile(CommonUtils.getQueryString("productId"));
    // 查询详细信息
    var customerInfo = findCustomerInfo(productId);
    // 填充表单数据
    CommonUtils.fillFormData("#detail", JSON.stringify(customerInfo));
    // 填充图片
    showHeadImg($("#detailsForm"), customerInfo.customerLogoUrl);
});

//查询客户详细信息
var findCustomerInfo = function(customerId) {
    var customerInfo = null;
    $.ajax({
        url : '/init/customer/findCustomer',
        data : CommonUtils.encapsulationData({
            customerId : customerId
        }),
        type : 'post',
        dataType : 'json',
        async : false,// 同步请求
        contentType : "application/json",
        success : function(data) {
            if (null != data) {
                customerInfo = data;
            }
        },
        error : function(req, status, err) {
            // 消息提示款
            errorFunc(req, status, err);
        }
    });
    return customerInfo;
}

//拼接加载图片
var showHeadImg = function(from, url){
    // 新增类型下拉控选项值件初始化
    var serverPath = CommonUtils.getServerRoot();
    var imgURL = url;
    from.find("#divIMG").show();
    var img = '<div id="imgItem" style="float:left">';
    img += '<div>';
    img += '<a class="fancybox" href="'+serverPath + imgURL+'" title="Logo图片">';
    img += '<img alt="image" id="fileUrl" name="fileUrl" style="width:120px;height:100px;margin: 0 5px 5px 0;" fileUrl="'+imgURL+'" src="'+serverPath + imgURL+'" />';
    img += '</a>';
    img += '</div>';
    img += '</div>';
    from.find("#divIMG #divImgDoc").append(img);
    // 加载图片预览
    $(".fancybox").fancybox({openEffect:"none",closeEffect:"none"});
}
